﻿#coding: utf-8

require 'json'

post '/login' do
	begin
		data = JSON.parse(request.body.string)
	rescue JSON::ParserError
		400
	end

	user = User.first(:login => data['login'])
	if user.nil? then
		404
	else
		if user.password.eql?(data['password']) then
			200
		else
			400
		end
	end

end
